package com.hdoit.ares.logical.acti.dao.impl;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.utils.FinderExpressionFactory;
import com.hdoit.ares.logical.acti.dao.ITaskGoldenBeanDao;
import com.hdoit.ares.logical.acti.model.ActiReward;
import com.hdoit.ares.logical.acti.model.TaskGoldenBean;
import com.hdoit.ares.logical.cust.model.Customer;
/**
 * @author      caochengmeng
 * @email       
 * @createtime  2018年03月29日 15:26:43
 * @comment
 */
@Component
public class TaskGoldenBeanDaoImpl extends SuperDao<TaskGoldenBean> implements ITaskGoldenBeanDao{

	@Override
	public TaskGoldenBean queryModelByCustomerId(String customerId) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(TaskGoldenBean.class)
						.andEq("customerId",customerId);
		return queryModel(finderExpression);
	}
	
	@Override
	public boolean updateTaskSortByGoldenBean(TaskGoldenBean taskGoldenBean) {
		IFinderExpression updateExpression=FinderExpressionFactory.createExpression();
		updateExpression.update(Customer.class)
						.andEq("customerId", taskGoldenBean.getCustomerId());
		if(!StringUtils.isEmpty(taskGoldenBean.getSort())){
			updateExpression.set("sort=#{sort}")
							.setParam("sort", taskGoldenBean.getSort());
		}
		return update(updateExpression)>0;
	}

}